package org.bookshare.validator.error;

import org.benetech.beans.error.ValidationError;
import org.benetech.beans.error.ValidationError.Severity;


/**
 * A page number within the document doesn't relate properly to the other page
 * numbers. Note that "numbers" may be strings, e.g. "i", "ii", "x"
 * @author Reuben Firmin
 */
public final class PageNumberValidationError implements ValidationError
{

    private String pageNum;
    private String prevPage;
    private String nextPage;
    private String msg;
    private Severity severity;

    /**
     * Constructor.
     * @param pageNum The content of the page number
     * @param prevPage The content of the previous page number
     * @param nextPage The content of the next page number
     * @param msg The message to display to the user
     * @param severity The severity of the problem
     */
    public PageNumberValidationError(final String pageNum, final String prevPage, final String nextPage,
    		final String msg, final Severity severity)
    {
        this.pageNum = pageNum;
        this.prevPage = prevPage;
        this.nextPage = nextPage;
        this.msg = msg;
        this.severity = severity;
    }

    /**
     * The message to display to the user.
     * @return Not null
     */
    public String getMsg() {
        return msg;
    }

    /**
     * The next page number.
     * @return Not null
     */
    public String getNextPage() {
        return nextPage;
    }

    /**
     * The page number with the problem.
     * @return Not null.
     */
    public String getPageNum() {
        return pageNum;
    }

    /**
     * The previous page number.
     * @return Not null
     */
    public String getPrevPage() {
        return prevPage;
    }

    /**
     * The severity of the problem.
     * @return not null
     */
    public Severity getSeverity() {
        return severity;
    }

    /**
     * {@inheritDoc}
     */
    public String toString() {
        return msg + " Page:" + pageNum
            + (prevPage != null ? " Previous:" + prevPage : "")
            + (nextPage != null ? " Next:" + nextPage : "");
    }
}
